<?php
/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of MoneyOpsclass
 *
 * @author marius
 */

require_once ("Money.class.php");
require_once ("MoneyFactory.class.php");
require_once ("MoneyExceptions.php");

class MoneyOps {
    public static function add($m1,$m2) {
	$exc=new IncompatiblesCurrenciesException("incompatible currencies");
	if (!$m1->sameCurrency($m2)) {
		throw new IncompatiblesCurrenciesException();
	}
        $_factory=MoneyFactory::getDefaultFactory();
    	return $_factory->createMoney(
		$m1->getValue()+$m2->getValue(),
		$m1->getCurrency());	
    }

    public static function sous($m1,$m2) {
        $exc=new IncompatiblesCurrenciesException("incompatible currencies");
        if (!$m1->sameCurrency($m2)) {
            throw new IncompatiblesCurrenciesException();
        }
        $_factory=MoneyFactory::getDefaultFactory();
        return $_factory->createMoney(
            $m2->getValue()-$m1->getValue(),
            $m1->getCurrency());
    }
}
?>
